/*
 * Copyright (C) 2019 The Turms Project
 * https://github.com/turms-im/turms
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: request/message/query_messages_request.proto

package im.turms.server.common.access.client.dto.request.message;

/**
 * Protobuf type {@code im.turms.proto.QueryMessagesRequest}
 */
public final class QueryMessagesRequest extends
    com.google.protobuf.GeneratedMessageV3 implements
    // @@protoc_insertion_point(message_implements:im.turms.proto.QueryMessagesRequest)
    QueryMessagesRequestOrBuilder {
private static final long serialVersionUID = 0L;
  // Use QueryMessagesRequest.newBuilder() to construct.
  private QueryMessagesRequest(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
    super(builder);
  }
  private QueryMessagesRequest() {
    ids_ = emptyLongList();
  }

  @java.lang.Override
  @SuppressWarnings({"unused"})
  protected java.lang.Object newInstance(
      UnusedPrivateParameter unused) {
    return new QueryMessagesRequest();
  }

  @java.lang.Override
  public final com.google.protobuf.UnknownFieldSet
  getUnknownFields() {
    return this.unknownFields;
  }
  private QueryMessagesRequest(
      com.google.protobuf.CodedInputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    this();
    if (extensionRegistry == null) {
      throw new java.lang.NullPointerException();
    }
    int mutable_bitField0_ = 0;
    com.google.protobuf.UnknownFieldSet.Builder unknownFields =
        com.google.protobuf.UnknownFieldSet.newBuilder();
    try {
      boolean done = false;
      while (!done) {
        int tag = input.readTag();
        switch (tag) {
          case 0:
            done = true;
            break;
          case 8: {
            if (!((mutable_bitField0_ & 0x00000001) != 0)) {
              ids_ = newLongList();
              mutable_bitField0_ |= 0x00000001;
            }
            ids_.addLong(input.readInt64());
            break;
          }
          case 10: {
            int length = input.readRawVarint32();
            int limit = input.pushLimit(length);
            if (!((mutable_bitField0_ & 0x00000001) != 0) && input.getBytesUntilLimit() > 0) {
              ids_ = newLongList();
              mutable_bitField0_ |= 0x00000001;
            }
            while (input.getBytesUntilLimit() > 0) {
              ids_.addLong(input.readInt64());
            }
            input.popLimit(limit);
            break;
          }
          case 16: {
            bitField0_ |= 0x00000001;
            size_ = input.readInt32();
            break;
          }
          case 24: {
            bitField0_ |= 0x00000002;
            areGroupMessages_ = input.readBool();
            break;
          }
          case 32: {
            bitField0_ |= 0x00000004;
            areSystemMessages_ = input.readBool();
            break;
          }
          case 40: {
            bitField0_ |= 0x00000008;
            fromId_ = input.readInt64();
            break;
          }
          case 48: {
            bitField0_ |= 0x00000010;
            deliveryDateAfter_ = input.readInt64();
            break;
          }
          case 56: {
            bitField0_ |= 0x00000020;
            deliveryDateBefore_ = input.readInt64();
            break;
          }
          case 64: {

            withTotal_ = input.readBool();
            break;
          }
          default: {
            if (!parseUnknownField(
                input, unknownFields, extensionRegistry, tag)) {
              done = true;
            }
            break;
          }
        }
      }
    } catch (com.google.protobuf.InvalidProtocolBufferException e) {
      throw e.setUnfinishedMessage(this);
    } catch (com.google.protobuf.UninitializedMessageException e) {
      throw e.asInvalidProtocolBufferException().setUnfinishedMessage(this);
    } catch (java.io.IOException e) {
      throw new com.google.protobuf.InvalidProtocolBufferException(
          e).setUnfinishedMessage(this);
    } finally {
      if (((mutable_bitField0_ & 0x00000001) != 0)) {
        ids_.makeImmutable(); // C
      }
      this.unknownFields = unknownFields.build();
      makeExtensionsImmutable();
    }
  }
  public static final com.google.protobuf.Descriptors.Descriptor
      getDescriptor() {
    return im.turms.server.common.access.client.dto.request.message.QueryMessagesRequestOuterClass.internal_static_im_turms_proto_QueryMessagesRequest_descriptor;
  }

  @java.lang.Override
  protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
      internalGetFieldAccessorTable() {
    return im.turms.server.common.access.client.dto.request.message.QueryMessagesRequestOuterClass.internal_static_im_turms_proto_QueryMessagesRequest_fieldAccessorTable
        .ensureFieldAccessorsInitialized(
            im.turms.server.common.access.client.dto.request.message.QueryMessagesRequest.class, im.turms.server.common.access.client.dto.request.message.QueryMessagesRequest.Builder.class);
  }

  private int bitField0_;
  public static final int IDS_FIELD_NUMBER = 1;
  private com.google.protobuf.Internal.LongList ids_;
  /**
   * <code>repeated int64 ids = 1;</code>
   * @return A list containing the ids.
   */
  @java.lang.Override
  public java.util.List<java.lang.Long>
      getIdsList() {
    return ids_;
  }
  /**
   * <code>repeated int64 ids = 1;</code>
   * @return The count of ids.
   */
  public int getIdsCount() {
    return ids_.size();
  }
  /**
   * <code>repeated int64 ids = 1;</code>
   * @param index The index of the element to return.
   * @return The ids at the given index.
   */
  public long getIds(int index) {
    return ids_.getLong(index);
  }
  private int idsMemoizedSerializedSize = -1;

  public static final int SIZE_FIELD_NUMBER = 2;
  private int size_;
  /**
   * <code>optional int32 size = 2;</code>
   * @return Whether the size field is set.
   */
  @java.lang.Override
  public boolean hasSize() {
    return ((bitField0_ & 0x00000001) != 0);
  }
  /**
   * <code>optional int32 size = 2;</code>
   * @return The size.
   */
  @java.lang.Override
  public int getSize() {
    return size_;
  }

  public static final int ARE_GROUP_MESSAGES_FIELD_NUMBER = 3;
  private boolean areGroupMessages_;
  /**
   * <code>optional bool are_group_messages = 3;</code>
   * @return Whether the areGroupMessages field is set.
   */
  @java.lang.Override
  public boolean hasAreGroupMessages() {
    return ((bitField0_ & 0x00000002) != 0);
  }
  /**
   * <code>optional bool are_group_messages = 3;</code>
   * @return The areGroupMessages.
   */
  @java.lang.Override
  public boolean getAreGroupMessages() {
    return areGroupMessages_;
  }

  public static final int ARE_SYSTEM_MESSAGES_FIELD_NUMBER = 4;
  private boolean areSystemMessages_;
  /**
   * <code>optional bool are_system_messages = 4;</code>
   * @return Whether the areSystemMessages field is set.
   */
  @java.lang.Override
  public boolean hasAreSystemMessages() {
    return ((bitField0_ & 0x00000004) != 0);
  }
  /**
   * <code>optional bool are_system_messages = 4;</code>
   * @return The areSystemMessages.
   */
  @java.lang.Override
  public boolean getAreSystemMessages() {
    return areSystemMessages_;
  }

  public static final int FROM_ID_FIELD_NUMBER = 5;
  private long fromId_;
  /**
   * <code>optional int64 from_id = 5;</code>
   * @return Whether the fromId field is set.
   */
  @java.lang.Override
  public boolean hasFromId() {
    return ((bitField0_ & 0x00000008) != 0);
  }
  /**
   * <code>optional int64 from_id = 5;</code>
   * @return The fromId.
   */
  @java.lang.Override
  public long getFromId() {
    return fromId_;
  }

  public static final int DELIVERY_DATE_AFTER_FIELD_NUMBER = 6;
  private long deliveryDateAfter_;
  /**
   * <code>optional int64 delivery_date_after = 6;</code>
   * @return Whether the deliveryDateAfter field is set.
   */
  @java.lang.Override
  public boolean hasDeliveryDateAfter() {
    return ((bitField0_ & 0x00000010) != 0);
  }
  /**
   * <code>optional int64 delivery_date_after = 6;</code>
   * @return The deliveryDateAfter.
   */
  @java.lang.Override
  public long getDeliveryDateAfter() {
    return deliveryDateAfter_;
  }

  public static final int DELIVERY_DATE_BEFORE_FIELD_NUMBER = 7;
  private long deliveryDateBefore_;
  /**
   * <code>optional int64 delivery_date_before = 7;</code>
   * @return Whether the deliveryDateBefore field is set.
   */
  @java.lang.Override
  public boolean hasDeliveryDateBefore() {
    return ((bitField0_ & 0x00000020) != 0);
  }
  /**
   * <code>optional int64 delivery_date_before = 7;</code>
   * @return The deliveryDateBefore.
   */
  @java.lang.Override
  public long getDeliveryDateBefore() {
    return deliveryDateBefore_;
  }

  public static final int WITH_TOTAL_FIELD_NUMBER = 8;
  private boolean withTotal_;
  /**
   * <code>bool with_total = 8;</code>
   * @return The withTotal.
   */
  @java.lang.Override
  public boolean getWithTotal() {
    return withTotal_;
  }

  private byte memoizedIsInitialized = -1;
  @java.lang.Override
  public final boolean isInitialized() {
    byte isInitialized = memoizedIsInitialized;
    if (isInitialized == 1) return true;
    if (isInitialized == 0) return false;

    memoizedIsInitialized = 1;
    return true;
  }

  @java.lang.Override
  public void writeTo(com.google.protobuf.CodedOutputStream output)
                      throws java.io.IOException {
    getSerializedSize();
    if (getIdsList().size() > 0) {
      output.writeUInt32NoTag(10);
      output.writeUInt32NoTag(idsMemoizedSerializedSize);
    }
    for (int i = 0; i < ids_.size(); i++) {
      output.writeInt64NoTag(ids_.getLong(i));
    }
    if (((bitField0_ & 0x00000001) != 0)) {
      output.writeInt32(2, size_);
    }
    if (((bitField0_ & 0x00000002) != 0)) {
      output.writeBool(3, areGroupMessages_);
    }
    if (((bitField0_ & 0x00000004) != 0)) {
      output.writeBool(4, areSystemMessages_);
    }
    if (((bitField0_ & 0x00000008) != 0)) {
      output.writeInt64(5, fromId_);
    }
    if (((bitField0_ & 0x00000010) != 0)) {
      output.writeInt64(6, deliveryDateAfter_);
    }
    if (((bitField0_ & 0x00000020) != 0)) {
      output.writeInt64(7, deliveryDateBefore_);
    }
    if (withTotal_ != false) {
      output.writeBool(8, withTotal_);
    }
    unknownFields.writeTo(output);
  }

  @java.lang.Override
  public int getSerializedSize() {
    int size = memoizedSize;
    if (size != -1) return size;

    size = 0;
    {
      int dataSize = 0;
      for (int i = 0; i < ids_.size(); i++) {
        dataSize += com.google.protobuf.CodedOutputStream
          .computeInt64SizeNoTag(ids_.getLong(i));
      }
      size += dataSize;
      if (!getIdsList().isEmpty()) {
        size += 1;
        size += com.google.protobuf.CodedOutputStream
            .computeInt32SizeNoTag(dataSize);
      }
      idsMemoizedSerializedSize = dataSize;
    }
    if (((bitField0_ & 0x00000001) != 0)) {
      size += com.google.protobuf.CodedOutputStream
        .computeInt32Size(2, size_);
    }
    if (((bitField0_ & 0x00000002) != 0)) {
      size += com.google.protobuf.CodedOutputStream
        .computeBoolSize(3, areGroupMessages_);
    }
    if (((bitField0_ & 0x00000004) != 0)) {
      size += com.google.protobuf.CodedOutputStream
        .computeBoolSize(4, areSystemMessages_);
    }
    if (((bitField0_ & 0x00000008) != 0)) {
      size += com.google.protobuf.CodedOutputStream
        .computeInt64Size(5, fromId_);
    }
    if (((bitField0_ & 0x00000010) != 0)) {
      size += com.google.protobuf.CodedOutputStream
        .computeInt64Size(6, deliveryDateAfter_);
    }
    if (((bitField0_ & 0x00000020) != 0)) {
      size += com.google.protobuf.CodedOutputStream
        .computeInt64Size(7, deliveryDateBefore_);
    }
    if (withTotal_ != false) {
      size += com.google.protobuf.CodedOutputStream
        .computeBoolSize(8, withTotal_);
    }
    size += unknownFields.getSerializedSize();
    memoizedSize = size;
    return size;
  }

  @java.lang.Override
  public boolean equals(final java.lang.Object obj) {
    if (obj == this) {
     return true;
    }
    if (!(obj instanceof im.turms.server.common.access.client.dto.request.message.QueryMessagesRequest)) {
      return super.equals(obj);
    }
    im.turms.server.common.access.client.dto.request.message.QueryMessagesRequest other = (im.turms.server.common.access.client.dto.request.message.QueryMessagesRequest) obj;

    if (!getIdsList()
        .equals(other.getIdsList())) return false;
    if (hasSize() != other.hasSize()) return false;
    if (hasSize()) {
      if (getSize()
          != other.getSize()) return false;
    }
    if (hasAreGroupMessages() != other.hasAreGroupMessages()) return false;
    if (hasAreGroupMessages()) {
      if (getAreGroupMessages()
          != other.getAreGroupMessages()) return false;
    }
    if (hasAreSystemMessages() != other.hasAreSystemMessages()) return false;
    if (hasAreSystemMessages()) {
      if (getAreSystemMessages()
          != other.getAreSystemMessages()) return false;
    }
    if (hasFromId() != other.hasFromId()) return false;
    if (hasFromId()) {
      if (getFromId()
          != other.getFromId()) return false;
    }
    if (hasDeliveryDateAfter() != other.hasDeliveryDateAfter()) return false;
    if (hasDeliveryDateAfter()) {
      if (getDeliveryDateAfter()
          != other.getDeliveryDateAfter()) return false;
    }
    if (hasDeliveryDateBefore() != other.hasDeliveryDateBefore()) return false;
    if (hasDeliveryDateBefore()) {
      if (getDeliveryDateBefore()
          != other.getDeliveryDateBefore()) return false;
    }
    if (getWithTotal()
        != other.getWithTotal()) return false;
    if (!unknownFields.equals(other.unknownFields)) return false;
    return true;
  }

  @java.lang.Override
  public int hashCode() {
    if (memoizedHashCode != 0) {
      return memoizedHashCode;
    }
    int hash = 41;
    hash = (19 * hash) + getDescriptor().hashCode();
    if (getIdsCount() > 0) {
      hash = (37 * hash) + IDS_FIELD_NUMBER;
      hash = (53 * hash) + getIdsList().hashCode();
    }
    if (hasSize()) {
      hash = (37 * hash) + SIZE_FIELD_NUMBER;
      hash = (53 * hash) + getSize();
    }
    if (hasAreGroupMessages()) {
      hash = (37 * hash) + ARE_GROUP_MESSAGES_FIELD_NUMBER;
      hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(
          getAreGroupMessages());
    }
    if (hasAreSystemMessages()) {
      hash = (37 * hash) + ARE_SYSTEM_MESSAGES_FIELD_NUMBER;
      hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(
          getAreSystemMessages());
    }
    if (hasFromId()) {
      hash = (37 * hash) + FROM_ID_FIELD_NUMBER;
      hash = (53 * hash) + com.google.protobuf.Internal.hashLong(
          getFromId());
    }
    if (hasDeliveryDateAfter()) {
      hash = (37 * hash) + DELIVERY_DATE_AFTER_FIELD_NUMBER;
      hash = (53 * hash) + com.google.protobuf.Internal.hashLong(
          getDeliveryDateAfter());
    }
    if (hasDeliveryDateBefore()) {
      hash = (37 * hash) + DELIVERY_DATE_BEFORE_FIELD_NUMBER;
      hash = (53 * hash) + com.google.protobuf.Internal.hashLong(
          getDeliveryDateBefore());
    }
    hash = (37 * hash) + WITH_TOTAL_FIELD_NUMBER;
    hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(
        getWithTotal());
    hash = (29 * hash) + unknownFields.hashCode();
    memoizedHashCode = hash;
    return hash;
  }

  public static im.turms.server.common.access.client.dto.request.message.QueryMessagesRequest parseFrom(
      java.nio.ByteBuffer data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }
  public static im.turms.server.common.access.client.dto.request.message.QueryMessagesRequest parseFrom(
      java.nio.ByteBuffer data,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }
  public static im.turms.server.common.access.client.dto.request.message.QueryMessagesRequest parseFrom(
      com.google.protobuf.ByteString data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }
  public static im.turms.server.common.access.client.dto.request.message.QueryMessagesRequest parseFrom(
      com.google.protobuf.ByteString data,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }
  public static im.turms.server.common.access.client.dto.request.message.QueryMessagesRequest parseFrom(byte[] data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }
  public static im.turms.server.common.access.client.dto.request.message.QueryMessagesRequest parseFrom(
      byte[] data,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }
  public static im.turms.server.common.access.client.dto.request.message.QueryMessagesRequest parseFrom(java.io.InputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseWithIOException(PARSER, input);
  }
  public static im.turms.server.common.access.client.dto.request.message.QueryMessagesRequest parseFrom(
      java.io.InputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseWithIOException(PARSER, input, extensionRegistry);
  }
  public static im.turms.server.common.access.client.dto.request.message.QueryMessagesRequest parseDelimitedFrom(java.io.InputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseDelimitedWithIOException(PARSER, input);
  }
  public static im.turms.server.common.access.client.dto.request.message.QueryMessagesRequest parseDelimitedFrom(
      java.io.InputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
  }
  public static im.turms.server.common.access.client.dto.request.message.QueryMessagesRequest parseFrom(
      com.google.protobuf.CodedInputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseWithIOException(PARSER, input);
  }
  public static im.turms.server.common.access.client.dto.request.message.QueryMessagesRequest parseFrom(
      com.google.protobuf.CodedInputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseWithIOException(PARSER, input, extensionRegistry);
  }

  @java.lang.Override
  public Builder newBuilderForType() { return newBuilder(); }
  public static Builder newBuilder() {
    return DEFAULT_INSTANCE.toBuilder();
  }
  public static Builder newBuilder(im.turms.server.common.access.client.dto.request.message.QueryMessagesRequest prototype) {
    return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
  }
  @java.lang.Override
  public Builder toBuilder() {
    return this == DEFAULT_INSTANCE
        ? new Builder() : new Builder().mergeFrom(this);
  }

  @java.lang.Override
  protected Builder newBuilderForType(
      com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
    Builder builder = new Builder(parent);
    return builder;
  }
  /**
   * Protobuf type {@code im.turms.proto.QueryMessagesRequest}
   */
  public static final class Builder extends
      com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
      // @@protoc_insertion_point(builder_implements:im.turms.proto.QueryMessagesRequest)
      im.turms.server.common.access.client.dto.request.message.QueryMessagesRequestOrBuilder {
    public static final com.google.protobuf.Descriptors.Descriptor
        getDescriptor() {
      return im.turms.server.common.access.client.dto.request.message.QueryMessagesRequestOuterClass.internal_static_im_turms_proto_QueryMessagesRequest_descriptor;
    }

    @java.lang.Override
    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
        internalGetFieldAccessorTable() {
      return im.turms.server.common.access.client.dto.request.message.QueryMessagesRequestOuterClass.internal_static_im_turms_proto_QueryMessagesRequest_fieldAccessorTable
          .ensureFieldAccessorsInitialized(
              im.turms.server.common.access.client.dto.request.message.QueryMessagesRequest.class, im.turms.server.common.access.client.dto.request.message.QueryMessagesRequest.Builder.class);
    }

    // Construct using im.turms.server.common.access.client.dto.request.message.QueryMessagesRequest.newBuilder()
    private Builder() {
      maybeForceBuilderInitialization();
    }

    private Builder(
        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
      super(parent);
      maybeForceBuilderInitialization();
    }
    private void maybeForceBuilderInitialization() {
      if (com.google.protobuf.GeneratedMessageV3
              .alwaysUseFieldBuilders) {
      }
    }
    @java.lang.Override
    public Builder clear() {
      super.clear();
      ids_ = emptyLongList();
      bitField0_ = (bitField0_ & ~0x00000001);
      size_ = 0;
      bitField0_ = (bitField0_ & ~0x00000002);
      areGroupMessages_ = false;
      bitField0_ = (bitField0_ & ~0x00000004);
      areSystemMessages_ = false;
      bitField0_ = (bitField0_ & ~0x00000008);
      fromId_ = 0L;
      bitField0_ = (bitField0_ & ~0x00000010);
      deliveryDateAfter_ = 0L;
      bitField0_ = (bitField0_ & ~0x00000020);
      deliveryDateBefore_ = 0L;
      bitField0_ = (bitField0_ & ~0x00000040);
      withTotal_ = false;

      return this;
    }

    @java.lang.Override
    public com.google.protobuf.Descriptors.Descriptor
        getDescriptorForType() {
      return im.turms.server.common.access.client.dto.request.message.QueryMessagesRequestOuterClass.internal_static_im_turms_proto_QueryMessagesRequest_descriptor;
    }

    @java.lang.Override
    public im.turms.server.common.access.client.dto.request.message.QueryMessagesRequest getDefaultInstanceForType() {
      return im.turms.server.common.access.client.dto.request.message.QueryMessagesRequest.getDefaultInstance();
    }

    @java.lang.Override
    public im.turms.server.common.access.client.dto.request.message.QueryMessagesRequest build() {
      im.turms.server.common.access.client.dto.request.message.QueryMessagesRequest result = buildPartial();
      if (!result.isInitialized()) {
        throw newUninitializedMessageException(result);
      }
      return result;
    }

    @java.lang.Override
    public im.turms.server.common.access.client.dto.request.message.QueryMessagesRequest buildPartial() {
      im.turms.server.common.access.client.dto.request.message.QueryMessagesRequest result = new im.turms.server.common.access.client.dto.request.message.QueryMessagesRequest(this);
      int from_bitField0_ = bitField0_;
      int to_bitField0_ = 0;
      if (((bitField0_ & 0x00000001) != 0)) {
        ids_.makeImmutable();
        bitField0_ = (bitField0_ & ~0x00000001);
      }
      result.ids_ = ids_;
      if (((from_bitField0_ & 0x00000002) != 0)) {
        result.size_ = size_;
        to_bitField0_ |= 0x00000001;
      }
      if (((from_bitField0_ & 0x00000004) != 0)) {
        result.areGroupMessages_ = areGroupMessages_;
        to_bitField0_ |= 0x00000002;
      }
      if (((from_bitField0_ & 0x00000008) != 0)) {
        result.areSystemMessages_ = areSystemMessages_;
        to_bitField0_ |= 0x00000004;
      }
      if (((from_bitField0_ & 0x00000010) != 0)) {
        result.fromId_ = fromId_;
        to_bitField0_ |= 0x00000008;
      }
      if (((from_bitField0_ & 0x00000020) != 0)) {
        result.deliveryDateAfter_ = deliveryDateAfter_;
        to_bitField0_ |= 0x00000010;
      }
      if (((from_bitField0_ & 0x00000040) != 0)) {
        result.deliveryDateBefore_ = deliveryDateBefore_;
        to_bitField0_ |= 0x00000020;
      }
      result.withTotal_ = withTotal_;
      result.bitField0_ = to_bitField0_;
      onBuilt();
      return result;
    }

    @java.lang.Override
    public Builder clone() {
      return super.clone();
    }
    @java.lang.Override
    public Builder setField(
        com.google.protobuf.Descriptors.FieldDescriptor field,
        java.lang.Object value) {
      return super.setField(field, value);
    }
    @java.lang.Override
    public Builder clearField(
        com.google.protobuf.Descriptors.FieldDescriptor field) {
      return super.clearField(field);
    }
    @java.lang.Override
    public Builder clearOneof(
        com.google.protobuf.Descriptors.OneofDescriptor oneof) {
      return super.clearOneof(oneof);
    }
    @java.lang.Override
    public Builder setRepeatedField(
        com.google.protobuf.Descriptors.FieldDescriptor field,
        int index, java.lang.Object value) {
      return super.setRepeatedField(field, index, value);
    }
    @java.lang.Override
    public Builder addRepeatedField(
        com.google.protobuf.Descriptors.FieldDescriptor field,
        java.lang.Object value) {
      return super.addRepeatedField(field, value);
    }
    @java.lang.Override
    public Builder mergeFrom(com.google.protobuf.Message other) {
      if (other instanceof im.turms.server.common.access.client.dto.request.message.QueryMessagesRequest) {
        return mergeFrom((im.turms.server.common.access.client.dto.request.message.QueryMessagesRequest)other);
      } else {
        super.mergeFrom(other);
        return this;
      }
    }

    public Builder mergeFrom(im.turms.server.common.access.client.dto.request.message.QueryMessagesRequest other) {
      if (other == im.turms.server.common.access.client.dto.request.message.QueryMessagesRequest.getDefaultInstance()) return this;
      if (!other.ids_.isEmpty()) {
        if (ids_.isEmpty()) {
          ids_ = other.ids_;
          bitField0_ = (bitField0_ & ~0x00000001);
        } else {
          ensureIdsIsMutable();
          ids_.addAll(other.ids_);
        }
        onChanged();
      }
      if (other.hasSize()) {
        setSize(other.getSize());
      }
      if (other.hasAreGroupMessages()) {
        setAreGroupMessages(other.getAreGroupMessages());
      }
      if (other.hasAreSystemMessages()) {
        setAreSystemMessages(other.getAreSystemMessages());
      }
      if (other.hasFromId()) {
        setFromId(other.getFromId());
      }
      if (other.hasDeliveryDateAfter()) {
        setDeliveryDateAfter(other.getDeliveryDateAfter());
      }
      if (other.hasDeliveryDateBefore()) {
        setDeliveryDateBefore(other.getDeliveryDateBefore());
      }
      if (other.getWithTotal() != false) {
        setWithTotal(other.getWithTotal());
      }
      this.mergeUnknownFields(other.unknownFields);
      onChanged();
      return this;
    }

    @java.lang.Override
    public final boolean isInitialized() {
      return true;
    }

    @java.lang.Override
    public Builder mergeFrom(
        com.google.protobuf.CodedInputStream input,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws java.io.IOException {
      im.turms.server.common.access.client.dto.request.message.QueryMessagesRequest parsedMessage = null;
      try {
        parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
      } catch (com.google.protobuf.InvalidProtocolBufferException e) {
        parsedMessage = (im.turms.server.common.access.client.dto.request.message.QueryMessagesRequest) e.getUnfinishedMessage();
        throw e.unwrapIOException();
      } finally {
        if (parsedMessage != null) {
          mergeFrom(parsedMessage);
        }
      }
      return this;
    }
    private int bitField0_;

    private com.google.protobuf.Internal.LongList ids_ = emptyLongList();
    private void ensureIdsIsMutable() {
      if (!((bitField0_ & 0x00000001) != 0)) {
        ids_ = mutableCopy(ids_);
        bitField0_ |= 0x00000001;
       }
    }
    /**
     * <code>repeated int64 ids = 1;</code>
     * @return A list containing the ids.
     */
    public java.util.List<java.lang.Long>
        getIdsList() {
      return ((bitField0_ & 0x00000001) != 0) ?
               java.util.Collections.unmodifiableList(ids_) : ids_;
    }
    /**
     * <code>repeated int64 ids = 1;</code>
     * @return The count of ids.
     */
    public int getIdsCount() {
      return ids_.size();
    }
    /**
     * <code>repeated int64 ids = 1;</code>
     * @param index The index of the element to return.
     * @return The ids at the given index.
     */
    public long getIds(int index) {
      return ids_.getLong(index);
    }
    /**
     * <code>repeated int64 ids = 1;</code>
     * @param index The index to set the value at.
     * @param value The ids to set.
     * @return This builder for chaining.
     */
    public Builder setIds(
        int index, long value) {
      ensureIdsIsMutable();
      ids_.setLong(index, value);
      onChanged();
      return this;
    }
    /**
     * <code>repeated int64 ids = 1;</code>
     * @param value The ids to add.
     * @return This builder for chaining.
     */
    public Builder addIds(long value) {
      ensureIdsIsMutable();
      ids_.addLong(value);
      onChanged();
      return this;
    }
    /**
     * <code>repeated int64 ids = 1;</code>
     * @param values The ids to add.
     * @return This builder for chaining.
     */
    public Builder addAllIds(
        java.lang.Iterable<? extends java.lang.Long> values) {
      ensureIdsIsMutable();
      com.google.protobuf.AbstractMessageLite.Builder.addAll(
          values, ids_);
      onChanged();
      return this;
    }
    /**
     * <code>repeated int64 ids = 1;</code>
     * @return This builder for chaining.
     */
    public Builder clearIds() {
      ids_ = emptyLongList();
      bitField0_ = (bitField0_ & ~0x00000001);
      onChanged();
      return this;
    }

    private int size_ ;
    /**
     * <code>optional int32 size = 2;</code>
     * @return Whether the size field is set.
     */
    @java.lang.Override
    public boolean hasSize() {
      return ((bitField0_ & 0x00000002) != 0);
    }
    /**
     * <code>optional int32 size = 2;</code>
     * @return The size.
     */
    @java.lang.Override
    public int getSize() {
      return size_;
    }
    /**
     * <code>optional int32 size = 2;</code>
     * @param value The size to set.
     * @return This builder for chaining.
     */
    public Builder setSize(int value) {
      bitField0_ |= 0x00000002;
      size_ = value;
      onChanged();
      return this;
    }
    /**
     * <code>optional int32 size = 2;</code>
     * @return This builder for chaining.
     */
    public Builder clearSize() {
      bitField0_ = (bitField0_ & ~0x00000002);
      size_ = 0;
      onChanged();
      return this;
    }

    private boolean areGroupMessages_ ;
    /**
     * <code>optional bool are_group_messages = 3;</code>
     * @return Whether the areGroupMessages field is set.
     */
    @java.lang.Override
    public boolean hasAreGroupMessages() {
      return ((bitField0_ & 0x00000004) != 0);
    }
    /**
     * <code>optional bool are_group_messages = 3;</code>
     * @return The areGroupMessages.
     */
    @java.lang.Override
    public boolean getAreGroupMessages() {
      return areGroupMessages_;
    }
    /**
     * <code>optional bool are_group_messages = 3;</code>
     * @param value The areGroupMessages to set.
     * @return This builder for chaining.
     */
    public Builder setAreGroupMessages(boolean value) {
      bitField0_ |= 0x00000004;
      areGroupMessages_ = value;
      onChanged();
      return this;
    }
    /**
     * <code>optional bool are_group_messages = 3;</code>
     * @return This builder for chaining.
     */
    public Builder clearAreGroupMessages() {
      bitField0_ = (bitField0_ & ~0x00000004);
      areGroupMessages_ = false;
      onChanged();
      return this;
    }

    private boolean areSystemMessages_ ;
    /**
     * <code>optional bool are_system_messages = 4;</code>
     * @return Whether the areSystemMessages field is set.
     */
    @java.lang.Override
    public boolean hasAreSystemMessages() {
      return ((bitField0_ & 0x00000008) != 0);
    }
    /**
     * <code>optional bool are_system_messages = 4;</code>
     * @return The areSystemMessages.
     */
    @java.lang.Override
    public boolean getAreSystemMessages() {
      return areSystemMessages_;
    }
    /**
     * <code>optional bool are_system_messages = 4;</code>
     * @param value The areSystemMessages to set.
     * @return This builder for chaining.
     */
    public Builder setAreSystemMessages(boolean value) {
      bitField0_ |= 0x00000008;
      areSystemMessages_ = value;
      onChanged();
      return this;
    }
    /**
     * <code>optional bool are_system_messages = 4;</code>
     * @return This builder for chaining.
     */
    public Builder clearAreSystemMessages() {
      bitField0_ = (bitField0_ & ~0x00000008);
      areSystemMessages_ = false;
      onChanged();
      return this;
    }

    private long fromId_ ;
    /**
     * <code>optional int64 from_id = 5;</code>
     * @return Whether the fromId field is set.
     */
    @java.lang.Override
    public boolean hasFromId() {
      return ((bitField0_ & 0x00000010) != 0);
    }
    /**
     * <code>optional int64 from_id = 5;</code>
     * @return The fromId.
     */
    @java.lang.Override
    public long getFromId() {
      return fromId_;
    }
    /**
     * <code>optional int64 from_id = 5;</code>
     * @param value The fromId to set.
     * @return This builder for chaining.
     */
    public Builder setFromId(long value) {
      bitField0_ |= 0x00000010;
      fromId_ = value;
      onChanged();
      return this;
    }
    /**
     * <code>optional int64 from_id = 5;</code>
     * @return This builder for chaining.
     */
    public Builder clearFromId() {
      bitField0_ = (bitField0_ & ~0x00000010);
      fromId_ = 0L;
      onChanged();
      return this;
    }

    private long deliveryDateAfter_ ;
    /**
     * <code>optional int64 delivery_date_after = 6;</code>
     * @return Whether the deliveryDateAfter field is set.
     */
    @java.lang.Override
    public boolean hasDeliveryDateAfter() {
      return ((bitField0_ & 0x00000020) != 0);
    }
    /**
     * <code>optional int64 delivery_date_after = 6;</code>
     * @return The deliveryDateAfter.
     */
    @java.lang.Override
    public long getDeliveryDateAfter() {
      return deliveryDateAfter_;
    }
    /**
     * <code>optional int64 delivery_date_after = 6;</code>
     * @param value The deliveryDateAfter to set.
     * @return This builder for chaining.
     */
    public Builder setDeliveryDateAfter(long value) {
      bitField0_ |= 0x00000020;
      deliveryDateAfter_ = value;
      onChanged();
      return this;
    }
    /**
     * <code>optional int64 delivery_date_after = 6;</code>
     * @return This builder for chaining.
     */
    public Builder clearDeliveryDateAfter() {
      bitField0_ = (bitField0_ & ~0x00000020);
      deliveryDateAfter_ = 0L;
      onChanged();
      return this;
    }

    private long deliveryDateBefore_ ;
    /**
     * <code>optional int64 delivery_date_before = 7;</code>
     * @return Whether the deliveryDateBefore field is set.
     */
    @java.lang.Override
    public boolean hasDeliveryDateBefore() {
      return ((bitField0_ & 0x00000040) != 0);
    }
    /**
     * <code>optional int64 delivery_date_before = 7;</code>
     * @return The deliveryDateBefore.
     */
    @java.lang.Override
    public long getDeliveryDateBefore() {
      return deliveryDateBefore_;
    }
    /**
     * <code>optional int64 delivery_date_before = 7;</code>
     * @param value The deliveryDateBefore to set.
     * @return This builder for chaining.
     */
    public Builder setDeliveryDateBefore(long value) {
      bitField0_ |= 0x00000040;
      deliveryDateBefore_ = value;
      onChanged();
      return this;
    }
    /**
     * <code>optional int64 delivery_date_before = 7;</code>
     * @return This builder for chaining.
     */
    public Builder clearDeliveryDateBefore() {
      bitField0_ = (bitField0_ & ~0x00000040);
      deliveryDateBefore_ = 0L;
      onChanged();
      return this;
    }

    private boolean withTotal_ ;
    /**
     * <code>bool with_total = 8;</code>
     * @return The withTotal.
     */
    @java.lang.Override
    public boolean getWithTotal() {
      return withTotal_;
    }
    /**
     * <code>bool with_total = 8;</code>
     * @param value The withTotal to set.
     * @return This builder for chaining.
     */
    public Builder setWithTotal(boolean value) {
      
      withTotal_ = value;
      onChanged();
      return this;
    }
    /**
     * <code>bool with_total = 8;</code>
     * @return This builder for chaining.
     */
    public Builder clearWithTotal() {
      
      withTotal_ = false;
      onChanged();
      return this;
    }
    @java.lang.Override
    public final Builder setUnknownFields(
        final com.google.protobuf.UnknownFieldSet unknownFields) {
      return super.setUnknownFields(unknownFields);
    }

    @java.lang.Override
    public final Builder mergeUnknownFields(
        final com.google.protobuf.UnknownFieldSet unknownFields) {
      return super.mergeUnknownFields(unknownFields);
    }


    // @@protoc_insertion_point(builder_scope:im.turms.proto.QueryMessagesRequest)
  }

  // @@protoc_insertion_point(class_scope:im.turms.proto.QueryMessagesRequest)
  private static final im.turms.server.common.access.client.dto.request.message.QueryMessagesRequest DEFAULT_INSTANCE;
  static {
    DEFAULT_INSTANCE = new im.turms.server.common.access.client.dto.request.message.QueryMessagesRequest();
  }

  public static im.turms.server.common.access.client.dto.request.message.QueryMessagesRequest getDefaultInstance() {
    return DEFAULT_INSTANCE;
  }

  private static final com.google.protobuf.Parser<QueryMessagesRequest>
      PARSER = new com.google.protobuf.AbstractParser<QueryMessagesRequest>() {
    @java.lang.Override
    public QueryMessagesRequest parsePartialFrom(
        com.google.protobuf.CodedInputStream input,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws com.google.protobuf.InvalidProtocolBufferException {
      return new QueryMessagesRequest(input, extensionRegistry);
    }
  };

  public static com.google.protobuf.Parser<QueryMessagesRequest> parser() {
    return PARSER;
  }

  @java.lang.Override
  public com.google.protobuf.Parser<QueryMessagesRequest> getParserForType() {
    return PARSER;
  }

  @java.lang.Override
  public im.turms.server.common.access.client.dto.request.message.QueryMessagesRequest getDefaultInstanceForType() {
    return DEFAULT_INSTANCE;
  }

}

